using System;
using Spread.Common.DataStore;
using FarPoint.Win.Spread;

namespace Spread.Worksheet.Features
{
    public partial class RowColMoving : Spread.Common.Features.Sample.BaseSampleControl
    {
        private AccessDataSource _dataSource;

        public RowColMoving()
        {
            InitializeComponent();
            Name = "Column and Row Moving";

            _dataSource = new DataService().AccessDataSource;

            InitSpreadSheet(fpSpread.ActiveSheet);

            chkAllowRowMove.CheckedChanged += ChkAllowRowMove_CheckedChanged;
            chkAllowMultiRowMove.CheckedChanged += ChkAllowMultiRowMove_CheckedChanged;
            chkAllowColMove.CheckedChanged += ChkAllowColMove_CheckedChanged;
            chkAllowMultiColumnMove.CheckedChanged += ChkAllowMultiColumnMove_CheckedChanged;
            chkShowMovingDragBand.CheckedChanged += ChkShowMovingDragBand_CheckedChanged;
        }

        private void InitSpreadSheet(SheetView sheet)
        {
            sheet.DataSource = _dataSource.GetDataFromTable("fpWine.mdb", "Customers");

            sheet.SetMultipleRowHeights(0, sheet.RowCount, 20);
        }

        #region CheckBox Events
        private void ChkAllowRowMove_CheckedChanged(object sender, EventArgs e)
        {
            fpSpread.AllowRowMove = chkAllowRowMove.Checked;
        }

        private void ChkAllowMultiRowMove_CheckedChanged(object sender, EventArgs e)
        {
            fpSpread.AllowRowMoveMultiple = chkAllowMultiRowMove.Checked;
        }

        private void ChkAllowColMove_CheckedChanged(object sender, EventArgs e)
        {
            fpSpread.AllowColumnMove = chkAllowColMove.Checked;
        }

        private void ChkAllowMultiColumnMove_CheckedChanged(object sender, EventArgs e)
        {
            fpSpread.AllowColumnMoveMultiple = chkAllowMultiColumnMove.Checked;
        }

        private void ChkShowMovingDragBand_CheckedChanged(object sender, EventArgs e)
        {
            fpSpread.ShowDragBandOnMoving = chkShowMovingDragBand.Checked;
        }
        #endregion
    }
}


//
//RowColMoving.Designer.cs
//


namespace Spread.Worksheet.Features
{
    partial class RowColMoving
    {
        /// <summary> 
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary> 
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Component Designer generated code

        /// <summary> 
        /// Required method for Designer support - do not modify 
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.fpSpread = new FarPoint.Win.Spread.FpSpread();
            this.fpSpread_Sheet1 = new FarPoint.Win.Spread.SheetView();
            this.GroupBox1 = new System.Windows.Forms.GroupBox();
            this.chkAllowMultiRowMove = new System.Windows.Forms.CheckBox();
            this.chkAllowMultiColumnMove = new System.Windows.Forms.CheckBox();
            this.chkAllowRowMove = new System.Windows.Forms.CheckBox();
            this.chkAllowColMove = new System.Windows.Forms.CheckBox();
            this.chkShowMovingDragBand = new System.Windows.Forms.CheckBox();
            this.pnlMain.SuspendLayout();
            this.pnlControls.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.fpSpread)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.fpSpread_Sheet1)).BeginInit();
            this.GroupBox1.SuspendLayout();
            this.SuspendLayout();
            // 
            // pnlMain
            // 
            this.pnlMain.Controls.Add(this.fpSpread);
            this.pnlMain.Size = new System.Drawing.Size(490, 487);
            // 
            // pnlControls
            // 
            this.pnlControls.Controls.Add(this.chkShowMovingDragBand);
            this.pnlControls.Controls.Add(this.GroupBox1);
            this.pnlControls.Size = new System.Drawing.Size(162, 487);
            // 
            // fpSpread
            // 
            this.fpSpread.Dock = System.Windows.Forms.DockStyle.Fill;
            this.fpSpread.Location = new System.Drawing.Point(0, 0);
            this.fpSpread.Name = "fpSpread";
            this.fpSpread.Sheets.AddRange(new FarPoint.Win.Spread.SheetView[] {
            this.fpSpread_Sheet1});
            this.fpSpread.Size = new System.Drawing.Size(490, 487);
            this.fpSpread.Skin = FarPoint.Win.Spread.DefaultSpreadSkins.Office2016White;
            this.fpSpread.StatusBarVisible = true;
            this.fpSpread.TabIndex = 0;
            // 
            // fpSpread_Sheet1
            // 
            this.fpSpread_Sheet1.Reset();
            this.fpSpread_Sheet1.SheetName = "Sheet1";
            // Formulas and custom names must be loaded with R1C1 reference style
            this.fpSpread_Sheet1.ReferenceStyle = FarPoint.Win.Spread.Model.ReferenceStyle.R1C1;
            this.fpSpread_Sheet1.ReferenceStyle = FarPoint.Win.Spread.Model.ReferenceStyle.A1;
            // 
            // GroupBox1
            // 
            this.GroupBox1.Controls.Add(this.chkAllowMultiRowMove);
            this.GroupBox1.Controls.Add(this.chkAllowMultiColumnMove);
            this.GroupBox1.Controls.Add(this.chkAllowRowMove);
            this.GroupBox1.Controls.Add(this.chkAllowColMove);
            this.GroupBox1.Dock = System.Windows.Forms.DockStyle.Top;
            this.GroupBox1.Location = new System.Drawing.Point(0, 0);
            this.GroupBox1.Margin = new System.Windows.Forms.Padding(2);
            this.GroupBox1.Name = "GroupBox1";
            this.GroupBox1.Padding = new System.Windows.Forms.Padding(2);
            this.GroupBox1.Size = new System.Drawing.Size(162, 145);
            this.GroupBox1.TabIndex = 26;
            this.GroupBox1.TabStop = false;
            this.GroupBox1.Text = "Move Rows/Columns";
            // 
            // chkAllowMultiRowMove
            // 
            this.chkAllowMultiRowMove.Location = new System.Drawing.Point(8, 49);
            this.chkAllowMultiRowMove.Margin = new System.Windows.Forms.Padding(2);
            this.chkAllowMultiRowMove.Name = "chkAllowMultiRowMove";
            this.chkAllowMultiRowMove.Size = new System.Drawing.Size(155, 23);
            this.chkAllowMultiRowMove.TabIndex = 19;
            this.chkAllowMultiRowMove.Text = "Allow Multiple Row Move";
            // 
            // chkAllowMultiColumnMove
            // 
            this.chkAllowMultiColumnMove.Location = new System.Drawing.Point(8, 103);
            this.chkAllowMultiColumnMove.Margin = new System.Windows.Forms.Padding(2);
            this.chkAllowMultiColumnMove.Name = "chkAllowMultiColumnMove";
            this.chkAllowMultiColumnMove.Size = new System.Drawing.Size(168, 23);
            this.chkAllowMultiColumnMove.TabIndex = 18;
            this.chkAllowMultiColumnMove.Text = "Allow Mulitple Column Move";
            // 
            // chkAllowRowMove
            // 
            this.chkAllowRowMove.Location = new System.Drawing.Point(8, 23);
            this.chkAllowRowMove.Margin = new System.Windows.Forms.Padding(2);
            this.chkAllowRowMove.Name = "chkAllowRowMove";
            this.chkAllowRowMove.Size = new System.Drawing.Size(108, 22);
            this.chkAllowRowMove.TabIndex = 16;
            this.chkAllowRowMove.Text = "Allow Row Move";
            // 
            // chkAllowColMove
            // 
            this.chkAllowColMove.Location = new System.Drawing.Point(8, 76);
            this.chkAllowColMove.Margin = new System.Windows.Forms.Padding(2);
            this.chkAllowColMove.Name = "chkAllowColMove";
            this.chkAllowColMove.Size = new System.Drawing.Size(130, 23);
            this.chkAllowColMove.TabIndex = 17;
            this.chkAllowColMove.Text = "Allow Column Move";
            // 
            // chkShowMovingDragBand
            // 
            this.chkShowMovingDragBand.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.chkShowMovingDragBand.Checked = true;
            this.chkShowMovingDragBand.CheckState = System.Windows.Forms.CheckState.Checked;
            this.chkShowMovingDragBand.Location = new System.Drawing.Point(8, 159);
            this.chkShowMovingDragBand.Margin = new System.Windows.Forms.Padding(2);
            this.chkShowMovingDragBand.Name = "chkShowMovingDragBand";
            this.chkShowMovingDragBand.Size = new System.Drawing.Size(154, 36);
            this.chkShowMovingDragBand.TabIndex = 27;
            this.chkShowMovingDragBand.Text = "Show Drag Band On Moving";
            // 
            // RowColMoving
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.Name = "RowColMoving";
            this.Size = new System.Drawing.Size(653, 487);
            this.pnlMain.ResumeLayout(false);
            this.pnlControls.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.fpSpread)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.fpSpread_Sheet1)).EndInit();
            this.GroupBox1.ResumeLayout(false);
            this.ResumeLayout(false);

        }

        #endregion

        private FarPoint.Win.Spread.FpSpread fpSpread;
        private FarPoint.Win.Spread.SheetView fpSpread_Sheet1;
        internal System.Windows.Forms.GroupBox GroupBox1;
        internal System.Windows.Forms.CheckBox chkAllowMultiRowMove;
        internal System.Windows.Forms.CheckBox chkAllowMultiColumnMove;
        internal System.Windows.Forms.CheckBox chkAllowRowMove;
        internal System.Windows.Forms.CheckBox chkAllowColMove;
        internal System.Windows.Forms.CheckBox chkShowMovingDragBand;
    }
}
